//
//  HeaderViewDiscover.m
//  test1
//
//  Created by chen on 16/10/31.
//  Copyright © 2016年 chen. All rights reserved.
//

#import "HeaderViewDiscover.h"
#import "Masonry.h"

#define COUNT 3

@implementation HeaderViewDiscover

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
        
    }
    return self;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    NSLog(@"view");
}

-(void)setupUI {
    
    CGFloat widthBtn = self.bounds.size.width / COUNT;
    CGSize sizeBtn = CGSizeMake(widthBtn, self.bounds.size.height);
    
    //添加三个按钮
    NSMutableArray *arrBtn = [NSMutableArray array];
    for (NSInteger index = 0; index < COUNT; index++) {
        UIButton *button = [[UIButton alloc]init];
        button.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:button];
        [arrBtn addObject:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self);
            make.left.mas_equalTo(self).offset(index * widthBtn);
            make.size.mas_equalTo(sizeBtn);
        }];
        NSString *text = index == 0?@"全类型":(index == 1?@"全时段":@"全价位");
        [button setTitle:text forState:UIControlStateNormal];
        
        button.titleLabel.font = [UIFont systemFontOfSize:15];
    }
    
    self.arrBtn = arrBtn.copy;
    
    
}


@end
